FROM php:7.3-fpm

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

# Install modules
RUN apt-get update
RUN apt-get install -y \
        git \
        curl \
        openssl \
        wget \
        htop \
        vim \
        libssl-dev \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        libicu-dev \
        libpcre3 libpcre3-dev \
        zlib1g-dev \
             --no-install-recommends

# Install composer && g lobal asset plugin
ENV COMPOSER_HOME /root/.composer
ENV PATH /root/. composer/vendor/bin:$PATH
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
    && composer config -g repo.packagist composer https://packagist.phpcomposer.com

CMD vim
# #install extension
RUN apt-get install -y libzip-dev && docker-php-ext-install zip 
RUN docker-php-ext-install intl 
RUN docker-php-ext-install mbstring 
RUN docker-php-ext-install pdo_mysql 
RUN docker-php-ext-install pcntl 
RUN docker-php-ext-install bcmath

#install gd
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd

RUN apt-get install -y nginx

RUN apt-get purge -y g++ \
    && apt-get autoremove -y \
    && rm -r /var/lib/apt/lists/* \
    && rm -rf /tmp/*

WORKDIR /var/www/html

RUN git clone https://gitee.com/kalcaddle/KODExplorer.git kod

RUN chmod -R 777 /var/www/html

RUN usermod -u 1000 www-data

COPY ./nginx.conf /etc/nginx/nginx.conf

EXPOSE 80 443

CMD ["sh", '-c', 'nginx && php-fpm']
